<template>
  <div>
    讲师列表
    <div v-for="(item,index) in items" :key="index">
      <a :href="'teacher/'+item.id">{{ item.name }}</a>
    </div>
  </div>
</template>
<script>
import teacherApi from '~/api/teacher'
export default {
  // 同步获取数据
  async asyncData() {
    console.log('asyncData')
    const response = await teacherApi.getList()
    console.log(response)
    return {
      items: response.data.items// 报错：response未定义
    }
  },

  data() {
    return {
      test: 'test'// 里的数据最后会和asyncData中的数据定义合并
    }
  }
}
</script>
